package com.example.server.controller;

import com.example.server.entity.CusServer;
import com.example.server.service.JobService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/")
public class ServerController {
    @Resource(name = "JobServiceImpl")
    private JobService jobService;

    @RequestMapping("/createServe")
    public String createServe(@ModelAttribute CusServer cusServer , HttpServletRequest request){

        jobService.add(cusServer);

        request.setAttribute("msg","创建成功!");
        return "/service/create";
    }

    @RequestMapping("/queryServerAll")
    public String queryAll(@ModelAttribute CusServer cusServer , HttpServletRequest request){

        List<CusServer> dataList =  jobService.queryAll();

        request.setAttribute("dataList",dataList);
        return "/service/details";
    }
}
